package src.tree;

import java.util.ArrayList;
import java.util.List;

public class no257 {//二叉树的所有路径，回溯

    List<String> result = new ArrayList<>();

    public List<String> binaryTreePaths(TreeNode root) {
        deal(root, "");
        return result;
    }

    public void deal(TreeNode node, String s) {
        if (node == null)
            return;
        if (node.left == null && node.right == null) {
            result.add(s + node.val);
            return;
        }
        String tmp = s + node.val + "->";
        deal(node.left, tmp);
        deal(node.right, tmp);
    }

}
